package com.whut.mobilesafe.activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.CheckBox;
import android.widget.CompoundButton;

import com.whut.mobilesafe.R;
import com.whut.mobilesafe.utils.PrefUtils;

public class Step4Activity extends BaseStepActivity {

    private CheckBox cbProtect;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_setup4);

        cbProtect = (CheckBox)findViewById(R.id.cb_protect);
        boolean protect = PrefUtils.getBoolean("protect", false, this);
        cbProtect.setChecked(protect);

        cbProtect.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (isChecked) {
                    cbProtect.setText("防盗保护已经开启");
                    PrefUtils.putBoolean("protect", true,
                            getApplicationContext());
                } else {
                    cbProtect.setText("您没有开启防盗保护");
                    PrefUtils.putBoolean("protect", false,
                            getApplicationContext());
                }
            }
        });
    }


    @Override
    public void showNext() {
        //表示已经配置过了
        PrefUtils.putBoolean("configed",true,this);

        startActivity(new Intent(getApplicationContext(), LostAndFoundActivity.class));
        finish();
        overridePendingTransition(R.anim.anim_right_in, R.anim.anim_right_out);
    }

    @Override
    public void showPrevious() {
        startActivity(new Intent(getApplicationContext(), Step3Activity.class));
        finish();
        overridePendingTransition(R.anim.anim_left_in, R.anim.anim_left_out);
    }
}
